package lyh0506;
import java.util.Scanner;
class Account{
	
	private int balance;
	
	public Account(int balance){
		this.balance=balance;
	}
	
	public int getBalance() {
		return balance;
	}
	
	public void setBalance(int balance) {
		this.balance = balance;
	}
	
	public synchronized void deposit(int money){
		setBalance(this.balance+money);
		notify();
	}
	
	public synchronized void withdraw(int money){
		try{
			while(this.getBalance()<=0){
				wait();
			}
		}catch(Exception e){
			System.out.println(e);
		}
		setBalance(this.balance-money);
		notify();
	}
	
}
